package com.stylefeng.guns.biz.api.controller;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.result.BaseResultVo;
import com.stylefeng.guns.modular.platform.model.BuyerDemand;
import com.stylefeng.guns.modular.platform.service.IBuyerDemandService;

/**
 * 控制器
 *
 * @author yangliwei
 * @Date 2018-07-13 19:10:29
 */
@Controller
@RequestMapping("/api/pc/buyerDemand")
public class ApiBuyerDemandController extends BaseController {
	
    @Autowired
    private IBuyerDemandService buyerDemandService;

    /**
     * 获取列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public BaseResultVo list(Page<BuyerDemand> page,String userId) {
		EntityWrapper<BuyerDemand> wp = new EntityWrapper<BuyerDemand>();
		wp.eq("user_id", userId);
		return buyerDemandService.selectBuyerDemandPage(page,wp);
    }

    /**
     * 新增
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public BaseResultVo add(@RequestBody BuyerDemand buyerDemand) {
    	return buyerDemandService.addBuyerDemand(buyerDemand);
    }

    /**
     * 删除
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public BaseResultVo delete(@RequestParam Integer buyerDemandId) {
    	return buyerDemandService.deleteBuyerDemandById(buyerDemandId);
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public BaseResultVo update(BuyerDemand buyerDemand) {
    	return buyerDemandService.updateBuyerDemandById(buyerDemand);
    }

    /**
     * 详情
     */
    @RequestMapping(value = "/detail/{buyerDemandId}")
    @ResponseBody
    public BaseResultVo detail(@PathVariable("buyerDemandId") Integer buyerDemandId) {
        return buyerDemandService.selectBuyerDemandById(buyerDemandId);
    }
}
